﻿<%@ Page Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="PR_IncomeOnMonth.aspx.cs" Inherits="KPIS.GERP.GHRMS.APP.App_UI.Forms.PR_IncomeOnMonth" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<asp:Content ID="Content1" runat="server" contentplaceholderid="ContentPlaceHolder1">  
<link href="../../Styles/CssClass.css" rel="stylesheet" type="text/css" /> 
<telerik:RadScriptBlock runat="server" ID="scriptBlock">
        <script type="text/javascript">
          function isNumberKeyDot(event)  // ตัวเลขทศนิยม
          {
             var charCode = (event.which) ? event.which : event.keyCode
             if(charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46){
             //    alert("กรอกได้แต่ตัวเลขทศนิยมครับ!")
                 return false;
	          }
             return true;
          }
          function isNumberKey(event)  // ตัวเลขอย่างเดียว
          {
             var charCode = (event.which) ? event.which : event.keyCode
             if(charCode > 31 && (charCode < 48 || charCode > 57)){
//                 alert("กรอกได้แต่ตัวเลขครับ!")
                 return false;
	          }
             return true;
          }
          
          function onTextChange(sender) {
                    if (sender.get_value() == "") {
                        sender.set_text("");
                    }
          } 
          
            function openProjectDetails(id,idET)
            {
                radopen("PR_InComeSurchargeAnother.aspx?pay_seq=" + id +"&emp_seq="+ idET, "ProjectDtls");
                return false;
            }
            function closeRadWindow(sender, args)
             {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();
            }
            function pagerefresh()
             {
                    location.reload(false);
             }           

</script>
</telerik:RadScriptBlock>

<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
<Windows>
    <telerik:RadWindow 
        id="ProjectDtls" 
        runat="server"
        showcontentduringload="false"
        VisibleStatusbar="false"
        title="เงินเพิ่มอื่นๆ"
        width="750px"
        Height="470px"        
        Modal="true"
        Skin = "Vista"
        OnClientClose="closeRadWindow">
    </telerik:RadWindow>
</Windows>
<Windows>
    <telerik:RadWindow 
        ID="RadWindow1"  
        DestroyOnClose = "true"               
        Modal ="true"                
        VisibleStatusbar ="false"
        runat="server">
    </telerik:RadWindow>
</Windows>
</telerik:RadWindowManager>     
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest ="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
             <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel2" />
                </UpdatedControls>
              </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ddlEmployeeType">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ddlMonth">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="cmbFilterYear">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            
        </AjaxSettings>
    </telerik:RadAjaxManager>

    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" runat="server">
    </telerik:RadAjaxLoadingPanel>   
    
    
    <asp:Panel ID="Panel6" runat="server" >
        <table width="30%" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <div class="moduleDivSlim1000">
                        <div class="moduleDivBottom1000">
                            <table align="center" width="980px">

                                <tr>
                                    <td align="right">ประเภทบุคลากร :</td>
                                    <td align="left">
                                        <telerik:RadComboBox ID="ddlEmployeeType" runat="server"
                                            AllowCustomText="true"
                                            CausesValidation="false" DataTextField="Name"
                                            DataValueField="Sequence"
                                            EmptyMessage="...พิมพ์ที่นี่เพื่อช่วยค้นหา..." Filter="Contains"
                                            OnClientTextChange="onTextChange" Width="150px" AutoPostBack="True"
                                            OnSelectedIndexChanged="ddlEmployeeType_SelectedIndexChanged">
                                        </telerik:RadComboBox>
                                        <asp:RequiredFieldValidator ID="v7" runat="server"
                                            ControlToValidate="ddlEmployeeType" ErrorMessage="*">
                                        </asp:RequiredFieldValidator>
                                    </td>
                                    <td align="right">ประจำเดือน :</td>
                                    <td align="left">
                                        <telerik:RadComboBox ID="ddlMonth" runat="server" AutoPostBack="True"
                                            Width="100px" OnSelectedIndexChanged="ddlMonth_SelectedIndexChanged">

                                            <Items>
                                                <telerik:RadComboBoxItem runat="server" Text="มกราคม" Value="1" />
                                                <telerik:RadComboBoxItem runat="server" Text="กุมภาพันธ์" Value="2" />
                                                <telerik:RadComboBoxItem runat="server" Text="มีนาคม" Value="3" />
                                                <telerik:RadComboBoxItem runat="server" Text="เมษายน" Value="4" />
                                                <telerik:RadComboBoxItem runat="server" Text="พฤษภาคม" Value="5" />
                                                <telerik:RadComboBoxItem runat="server" Text="มิถุนายน" Value="6" />
                                                <telerik:RadComboBoxItem runat="server" Text="กรกฎาคม" Value="7" />
                                                <telerik:RadComboBoxItem runat="server" Text="สิงหาคม" Value="8" />
                                                <telerik:RadComboBoxItem runat="server" Text="กันยายน" Value="9" />
                                                <telerik:RadComboBoxItem runat="server" Text="ตุลาคม" Value="10" />
                                                <telerik:RadComboBoxItem runat="server" Text="พฤศจิกายน" Value="11" />
                                                <telerik:RadComboBoxItem runat="server" Text="ธันวาคม" Value="12" />

                                            </Items>

                                        </telerik:RadComboBox>
                                    </td>
                                    <td align="right">ปี พ.ศ : </td>
                                    <td align="left">
                                        <telerik:RadComboBox
                                            runat="server"
                                            ID="cmbFilterYear"
                                            DataValueField="Name"
                                            DataTextField="Name"
                                            Filter="Contains"
                                            CausesValidation="false"
                                            OnClientTextChange="onTextChange"
                                            Width="100px" AutoPostBack="True"
                                            OnSelectedIndexChanged="cmbYear_SelectedIndexChanged">
                                        </telerik:RadComboBox>
                                    </td>
                                    <td align="left">
                                        <asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click"
                                            Text="กรองข้อมูล" Visible="false" />
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>

                    <div class="moduleDivSlim1000x450" >
                        <div class="moduleDivBottom1000">

                            <table width="980px" align="center" runat="server" >
                                <tr>
                                    <td align="left" class="tableHeader" colspan="4">จัดทำข้อมูลเงินได้ประจำเดือน</td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:Panel ID="PanelGrid" runat="server" Width="980px" Height="400px">
                                            <telerik:RadGrid ID="RadGrid2" runat="server"
                                                AllowAutomaticDeletes="True"
                                                AllowFilteringByColumn="True"
                                                AllowMultiRowEdit="True"
                                                AllowMultiRowSelection="True"
                                                AllowPaging="True"
                                                AllowSorting="True"
                                                AutoGenerateColumns="False"
                                                EnableAJAX="True"
                                                EnableAJAXLoadingTemplate="True"
                                                GridLines="None"
                                                ShowFooter="True"
                                                GroupingSettings-GroupByFieldsSeparator="&nbsp;&nbsp;&nbsp;&nbsp;"
                                                GroupingSettings-GroupContinuedFormatString=""
                                                GroupingSettings-GroupContinuesFormatString=""
                                                GroupingSettings-GroupSplitFormat=""
                                                OnItemCommand="RadGrid2_ItemCommand"
                                                PageSize="100"
                                                Skin="Vista" Width="960px" >
                                                <MasterTableView AllowMultiColumnSorting="True" CellSpacing="-1"
                                                    ClientDataKeyNames="pay_dtls_seq"
                                                    CommandItemDisplay="Top"
                                                    DataKeyNames="pay_dtls_seq"
                                                    ShowGroupFooter="true"
                                                    InsertItemPageIndexAction="ShowItemOnCurrentPage"
                                                    NoMasterRecordsText="&lt; ไม่มีข้อมูล &gt;">
                                                    <CommandItemTemplate>
                                                        <table width="100%">
                                                            <tr>
                                                                <td>
                                                                    <asp:LinkButton ID="cmdAddNew" runat="server" CausesValidation="False"
                                                                        CommandName="InitInsert" Visible="true">
                                        <img alt="" src="../Images/Buttons/AddRecord.gif" 
                                            style="border: 0px; vertical-align: middle;" /> เพิ่มรายชื่อบุคลากร</asp:LinkButton>
                                                                    &nbsp;&nbsp;
                                                                </td>
                                                                <td align="right">
                                                                  <%--  <asp:LinkButton ID="cmdInsertSelect" runat="server" CausesValidation="False"
                                                                        CommandName="InsertSelect"
                                                                        Visible="<%# !RadGrid2.MasterTableView.IsItemInserted && RadGrid2.EditIndexes.Count <= 0 %>">
                                        <img alt="" src="../Images/Buttons/add.gif" 
                                            style="border: 0px; vertical-align: middle;" /> เพิ่มรายชื่อบุคลากร</asp:LinkButton>--%>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </CommandItemTemplate>
                                                    <CommandItemSettings ExportToPdfText="Export to PDF" />
                                                    <RowIndicatorColumn>
                                                        <HeaderStyle Width="20px" />
                                                    </RowIndicatorColumn>

                                                    <ExpandCollapseColumn Visible="True">
                                                        <HeaderStyle Width="20px" />
                                                    </ExpandCollapseColumn>
                                                    <GroupByExpressions>
                                                        <telerik:GridGroupByExpression>
                                                            <GroupByFields>
                                                                <telerik:GridGroupByField
                                                                    FieldName="job_site_name"
                                                                    HeaderText="Group" />
                                                            </GroupByFields>
                                                            <SelectFields>
                                                                <telerik:GridGroupByField
                                                                    FieldName="job_site_name"
                                                                    HeaderText="สังกัด : "
                                                                    HeaderValueSeparator=" " />
                                                            </SelectFields>
                                                        </telerik:GridGroupByExpression>
                                                    </GroupByExpressions>
                                                    <Columns>
                                                        <telerik:GridEditCommandColumn ButtonType="ImageButton"
                                                            EditText="คลิกเพื่อแก้ไขข้อมูล">
                                                            <HeaderStyle HorizontalAlign="Center" Width="15px" />
                                                        </telerik:GridEditCommandColumn>
                                                        <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete"
                                                            ConfirmDialogType="RadWindow" ConfirmText="ลบข้อมูลที่เลือก?"
                                                            Text="คลิกเพื่อลบข้อมูล" UniqueName="column1">
                                                            <HeaderStyle HorizontalAlign="Center" Width="10px" />
                                                        </telerik:GridButtonColumn>

                                                        <telerik:GridBoundColumn
                                                            DataField="pos_ref" HeaderText="เลขประจำตำแหน่ง"
                                                            ShowFilterIcon="false"
                                                            FilterControlWidth="100%"
                                                            CurrentFilterFunction="Contains"
                                                            AutoPostBackOnFilter="true"
                                                            HeaderStyle-HorizontalAlign="Center"
                                                            HeaderStyle-Width="80px"
                                                            ItemStyle-HorizontalAlign="Center"
                                                            UniqueName="pos_ref">                                
                                                        </telerik:GridBoundColumn>

                                                        <telerik:GridTemplateColumn
                                                            HeaderText="ชื่อ-สกุล"
                                                            DataField="full_name"
                                                            FilterControlWidth="100%"
                                                            AutoPostBackOnFilter="true"
                                                            CurrentFilterFunction="Contains"
                                                            ShowFilterIcon="False">
                                                            <ItemTemplate >
                                                                <%# Eval("full_name")%>
                                                            </ItemTemplate>
                                                            <HeaderStyle HorizontalAlign="Center" Width="150px" />
                                                        </telerik:GridTemplateColumn>

                                                        <telerik:GridBoundColumn DataField="pos_name" HeaderText="ตำแหน่ง"
                                                            ShowFilterIcon="false"
                                                            FilterControlWidth="100%"
                                                            CurrentFilterFunction="Contains"
                                                            AutoPostBackOnFilter="true"
                                                            UniqueName="pos_name">
                                                            <HeaderStyle Wrap="False" HorizontalAlign="Center"  Width="100px"/>
                                                        </telerik:GridBoundColumn>

                                                        <telerik:GridBoundColumn DataField="class_name"
                                                            HeaderText="ระดับ"
                                                            ShowFilterIcon="false"
                                                            FilterControlWidth="100%"
                                                            CurrentFilterFunction="Contains"
                                                            AutoPostBackOnFilter="true"
                                                            Aggregate="Custom"
                                                            FooterText="รวมเงินเดือน : "
                                                            FooterStyle-HorizontalAlign="Right"
                                                            UniqueName="class_name">
                                                            <FooterStyle HorizontalAlign="Right" />
                                                            <HeaderStyle HorizontalAlign="Center" Width="150px" />
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn
                                                            DataField="pd_salary" HeaderText="เงินเดือน"
                                                            Aggregate="Sum"
                                                            ShowFilterIcon="false"
                                                            FilterControlWidth="100%"
                                                            CurrentFilterFunction="Contains"
                                                            AutoPostBackOnFilter="true"
                                                            HeaderStyle-HorizontalAlign="Center"
                                                            HeaderStyle-Width="50px"
                                                            ItemStyle-HorizontalAlign="Center"
                                                            UniqueName="pd_salary" DataFormatString="{0:N0}">     
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn HeaderText="เงินได้อื่น"
                                                            DataField="sum_ext"
                                                            Aggregate="Sum"
                                                            ShowFilterIcon="false"
                                                            FilterControlWidth="100%"
                                                            CurrentFilterFunction="Contains"
                                                            AutoPostBackOnFilter="true"
                                                            HeaderStyle-HorizontalAlign="Center"
                                                            HeaderStyle-Width="50px"
                                                            ItemStyle-HorizontalAlign="Center"
                                                            UniqueName="sum_ext" DataFormatString="{0:N2}">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridCalculatedColumn HeaderText="รวมเงินรับ"
                                                            HeaderStyle-HorizontalAlign="Center"
                                                            HeaderStyle-Width="100px"
                                                            ItemStyle-HorizontalAlign="Center"
                                                            ShowFilterIcon="false"
                                                            FilterControlWidth="100%"
                                                            CurrentFilterFunction="Contains"
                                                            AutoPostBackOnFilter="true"
                                                            UniqueName="TotalIncome"
                                                            DataType="System.Double"
                                                            DataFields="pd_salary, sum_ext"
                                                            Expression="{0}+{1}"
                                                            FooterText=" "
                                                            Aggregate="Sum"
                                                            DataFormatString="{0:N2}" >
                                                        </telerik:GridCalculatedColumn>

                                                        <telerik:GridTemplateColumn AllowFiltering="false">

                                                            <ItemTemplate>
                                                                <asp:LinkButton ID="targetControl" runat="server" 
                                                                    Text='เงินเพิ่มอื่นๆ'
                                                                    OnClientClick='<%# string.Format("return openProjectDetails(\"{0}\",\"{1}\");", Eval("pay_seq"),Eval("emp_seq")) %>'></asp:LinkButton>
                                                            </ItemTemplate>
                                                            
                                                            <ItemStyle HorizontalAlign="Right" Wrap="False" />
                                                        </telerik:GridTemplateColumn>


                                                    </Columns>
                                                    <EditFormSettings EditFormType="WebUserControl"
                                                        UserControlName="../UserControls/PR_IncomeOnMonth.ascx">
                                                        <EditColumn UniqueName="EditCommandColumn1">
                                                        </EditColumn>
                                                    </EditFormSettings>
                                                    <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                                                </MasterTableView>
                                                <GroupingSettings GroupByFieldsSeparator="&nbsp;&nbsp;&nbsp;&nbsp;" GroupContinuedFormatString="" GroupContinuesFormatString="" GroupSplitFormat="" />
                                                <ClientSettings AllowColumnHide="True" AllowColumnsReorder="True" EnableRowHoverStyle="True" ReorderColumnsOnClient="True">
                                                    <Selecting AllowRowSelect="True" EnableDragToSelectRows="true" />
                                                    <Scrolling AllowScroll="True" UseStaticHeaders="false" />
                                                </ClientSettings>
                                                <FilterMenu EnableImageSprites="False">
                                                </FilterMenu>
                                            </telerik:RadGrid>
                                        </asp:Panel>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </td>
            </tr>
        </table>
    </asp:Panel>

</asp:Content>
